package com.ccp.dev.workflow.model;

import com.ccp.dev.core.basic.model.BaseModel;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * ClassDescribe:流程变量定义 Model对象
 * @author :jiayueqiao
 * Date: 2019-05-24
 * Since:1
 */
@XmlRootElement(name = "bpmDefVar")
@XmlAccessorType(XmlAccessType.NONE)
public class BpmDefVar extends BaseModel<BpmDefVar> {

    /**
     * 表名称
     */
    public static final String TABLE_NAME = "BPM_DEF_VARS";
    /**
     * 变量id
     */
    @XmlAttribute
    protected String varId;
    /**
     * 流程定义id
     */
    @XmlAttribute
    protected String modelId;
    /**
     * 变量名称
     */
    @XmlAttribute
    protected String varName;
    /**
     * 变量Key
     */
    @XmlAttribute
    protected String varKey;
    /**
     * 变量数据类型
     */
    @XmlAttribute
    protected String varDataType;
    /**
     * 默认值
     */
    @XmlAttribute
    protected String defValue;
    /**
     * 节点名称
     */
    @XmlAttribute
    protected String nodeName;
    /**
     *  流程历史版本
     */
    @XmlAttribute
    protected Long versionId;
    /**
     * 流程部署id
     */
    @XmlAttribute
    protected String deployId;
    /**
     * 节点id
     */
    @XmlAttribute
    protected String nodeId;
    /**
     * 作用域
     */
    @XmlAttribute
    protected String varScope;

    public void setVarId(String varId)
    {
        this.varId = varId;
    }
    public String getVarId()
    {
        return varId;
    }

    public void setModelId(String modelId)
    {
        this.modelId = modelId;
    }

    public String getModelId()
    {
        return modelId;
    }

    public void setVarName(String varName)
    {
        this.varName = varName;
    }
    public String getVarName()
    {
        return varName;
    }

    public void setVarKey(String varKey)
    {
        this.varKey = varKey;
    }
    public String getVarKey()
    {
        return varKey;
    }

    public void setVarDataType(String varDataType)
    {
        this.varDataType = varDataType;
    }

    public String getVarDataType()
    {
        return varDataType;
    }

    public void setDefValue(String defValue)
    {
        this.defValue = defValue;
    }

    public String getDefValue()
    {
        return defValue;
    }

    public void setNodeName(String nodeName)
    {
        this.nodeName = nodeName;
    }

    public String getNodeName()
    {
        return nodeName;
    }

    public void setVersionId(Long versionId)
    {
        this.versionId = versionId;
    }

    public Long getVersionId()
    {
        return versionId;
    }

    public void setDeployId(String deployId)
    {
        this.deployId = deployId;
    }

    public String getDeployId()
    {
        return deployId;
    }

    public void setNodeId(String nodeId)
    {
        this.nodeId = nodeId;
    }

    public String getNodeId()
    {
        return nodeId;
    }

    public void setVarScope(String varScope)
    {
        this.varScope = varScope;
    }

    public String getVarScope()
    {
        return varScope;
    }


    /**
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object object)
    {
        if (!(object instanceof BpmDefVar))
        {
            return false;
        }
        BpmDefVar rhs = (BpmDefVar) object;
        return new EqualsBuilder()
                .append(this.varId, rhs.varId)
                .append(this.modelId, rhs.modelId)
                .append(this.varName, rhs.varName)
                .append(this.varKey, rhs.varKey)
                .append(this.varDataType, rhs.varDataType)
                .append(this.defValue, rhs.defValue)
                .append(this.nodeName, rhs.nodeName)
                .append(this.versionId, rhs.versionId)
                .append(this.deployId, rhs.deployId)
                .append(this.nodeId, rhs.nodeId)
                .append(this.varScope, rhs.varScope)
                .isEquals();
    }

    /**
     * @see Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        return new HashCodeBuilder(-82280557, -700257973)
                .append(this.varId)
                .append(this.modelId)
                .append(this.varName)
                .append(this.varKey)
                .append(this.varDataType)
                .append(this.defValue)
                .append(this.nodeName)
                .append(this.versionId)
                .append(this.deployId)
                .append(this.nodeId)
                .append(this.varScope)
                .toHashCode();
    }

    /**
     * @see Object#toString()
     */
    @Override
    public String toString()
    {
        return new ToStringBuilder(this)
                .append("varId", this.varId)
                .append("defId", this.modelId)
                .append("varName", this.varName)
                .append("varKey", this.varKey)
                .append("varDataType", this.varDataType)
                .append("defValue", this.defValue)
                .append("nodeName", this.nodeName)
                .append("versionId", this.versionId)
                .append("deployId", this.deployId)
                .append("nodeId", this.nodeId)
                .append("varScope", this.varScope)
                .toString();
    }

    @Override
    public Object clone()
    {
        BpmDefVar obj=null;
        try{
            obj=(BpmDefVar)super.clone();
        }catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return obj;
    }
}
